#!/bin/bash
# Author: Redbrother
# Email: 728083668@qq.com
# WebSite: https://help.ubuntu.com/community/LiveCDCustomizationFromScratch
# license: None
set -e
#自定义版本项
ARCH=amd64

IMAGE=deepin-livecdnew

if [ "`whoami`" != "root" ]; then
	echo "User must be root 需要root权限."
	exit 0
fi

if [ "`which mkisofs`" == "" ]; then
	ln -s /usr/bin/genisoimage /usr/bin/mkisofs
fi

############################################

# source umountx.sh

# make iso file ; build an iso image
rm newcd/live/filesystem.squashfs
rm newcd/live/filesystem.packages

chroot  squashfs-root  dpkg-query -W --showformat='${Package} ${Version}\n' | tee newcd/live/filesystem.packages

mksquashfs squashfs-root newcd/live/filesystem.squashfs -e boot
cd newcd && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt && cd ..



#mkdir -p cdimage/.disk
#touch cdimage/ubuntu
#touch cdimage/.disk/base_installable
#echo "full_cd/single"        > cdimage/.disk/cd_type
#echo "Ubuntu Remix $RELEASE" > cdimage/.disk/info

mkisofs -o $IMAGE.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -r -V "$IMAGE" -cache-inodes -J -l newcd/

chmod  +666 $IMAGE.iso

echo -e "successfully done"


